package com.yunxie.novelservice.infra.basic.service.impl;

import com.yunxie.novelservice.infra.basic.entity.NovelDetails;
import com.yunxie.novelservice.infra.basic.mapper.NovelDetailsDao;
import com.yunxie.novelservice.infra.basic.service.NovelDetailsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 小说详情表(NovelDetails)表服务实现类
 *
 * @author makejava
 * @since 2025-02-19 16:57:22
 */
@Service("novelDetailsService")
public class NovelDetailsServiceImpl implements NovelDetailsService {
    @Resource
    private NovelDetailsDao novelDetailsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param detailId 主键
     * @return 实例对象
     */
    @Override
    public NovelDetails queryById(Long detailId) {
        return this.novelDetailsDao.queryById(detailId);
    }


    /**
     * 新增数据
     *
     * @param novelDetails 实例对象
     * @return 实例对象
     */
    @Override
    public NovelDetails insert(NovelDetails novelDetails) {
        this.novelDetailsDao.insert(novelDetails);
        return novelDetails;
    }

    /**
     * 修改数据
     *
     * @param novelDetails 实例对象
     * @return 实例对象
     */
    @Override
    public NovelDetails update(NovelDetails novelDetails) {
        this.novelDetailsDao.update(novelDetails);
        return this.queryById(novelDetails.getDetailId());
    }

    /**
     * 通过主键删除数据
     *
     * @param detailId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long detailId) {
        return this.novelDetailsDao.deleteById(detailId) > 0;
    }
}
